//
//  EnemyFactory.m
//  iFly
//
//  Created by User-10 on 12/7/14.
//  Copyright (c) 2014 TeamDifferent. All rights reserved.
//

#import "EnemyFactory.h"
#import "MissileEnemy.h"
#import "ShipEnemy.h"

@implementation EnemyFactory

+ (EnemyNode*) createEnemyWithType:(EnemyType)type inScene:(SKScene*) scene {
    EnemyNode *enemy;
    EnemyType enemyType = (EnemyType)arc4random_uniform(numberOfEnemyTypes);
    
    //selecting random Y position for enemy
    int r = arc4random()%((NSInteger)scene.frame.size.height - spawningRange) + spawningOffset;
    CGPoint position = CGPointMake(scene.frame.size.width,r);
    
    if (enemyType == EnemyTypeMissile) {
        enemy = [MissileEnemy missileWithPosition:position andHealth:missileHealth andPointsForKill:missilePointsForKill];
    }
    if(enemyType == EnemyTypeShip){
        enemy = [ShipEnemy shipWithPosition:position andHealth:shipHealth andPointsForKill:shipPointsForKill];
    }
    
    return enemy;
    
}

@end
